<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserRechargesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_recharges', function (Blueprint $table) {
            $table->id()->comment('用户充值记录表');
            $table->integer('user_id')->comment('用户id')->index();
            $table->string('order_number')->comment('订单号');
            $table->decimal('price',10,2)->comment('充值金额');
            $table->decimal('give_price',10,2)->nullable()->comment('购买赠送金额');
            $table->string('recharge_type',100)->comment('充值类型 officialAccount:公众号 applet:小程序 other:其他');
            $table->tinyInteger('is_paid')->default(1)->comment('是否支付 0:未支付 1:已支付')->index();
            $table->decimal('refund_price',10,2)->nullable()->comment('退款金额');
            $table->string('channel_type')->nullable()->comment('用户访问端标识');
            $table->timestamp('pay_time')->comment('充值支付时间');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_recharges');
    }
}
